@extends('layouts.auth')

@section('title', '会员注册_网站分类目录提交_免费网站目录外链_好年年 - 我们只推荐好网站')

@section('content')
    @if(count($errors) > 0)
        <blockquote class="layui-elem-quote layui-bg-red">
            @foreach($errors->all() as $error)
                {{ $error }} &nbsp;&nbsp;
            @endforeach
        </blockquote>
    @endif
    <div class="member-login">
        <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    会员注册
                    <span>
                            <a href="{{ route('login') }}">登录</a>
                        </span>
                </div>
                <div class="layui-card-body">
                    <div class="member-body">
                        <form class="layui-form layui-form-pane" method="POST" action="{{ route('register') }}">
                            {{ csrf_field() }}

                            <div class="layui-form-item">
                                <label class="layui-form-label">邮箱</label>
                                <div class="layui-input-block">
                                    <input type="email" name="email" value="{{ old('email') }}" required="" lay-verify="required|email" lay-verType="tips" placeholder="邮箱地址" autocomplete="on" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">账号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" value="{{ old('name') }}" required="" lay-verify="required" lay-verType="tips" placeholder="用户名" autocomplete="on" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">密码</label>
                                <div class="layui-input-block">
                                    <input type="password" name="password" required="" lay-verify="required" lay-verType="tips" placeholder="密码" autocomplete="new-password" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">确认密码</label>
                                <div class="layui-input-block">
                                    <input type="password" name="password_confirmation" required="" lay-verify="required" lay-verType="tips" placeholder="密码" autocomplete="new-password" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div id="embed-captcha"></div>
                                <p id="wait" class="layui-show">正在加载验证码......</p>
                                <span id="notice" class="layui-hide">
                                        <strong>请先完成验证</strong>
                                    </span>
                            </div>
                            <div class="layui-form-item">
                                <button id="embed-submit" class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="formRegister">注册</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
@endsection

@section('scriptsAfterJs')
    <script>
        layui.use(['layer', 'jquery'], function(){
            var layer = layui.layer ,$ = layui.jquery;
            var handlerEmbed = function (captchaObj) {
                $("#embed-submit").click(function (e) {
                    var validate = captchaObj.getValidate();
                    if (!validate) {
                        $("#notice")[0].className = "layui-show";
                        setTimeout(function () {
                            $("#notice")[0].className = "layui-hide";
                        }, 2000);
                        e.preventDefault();
                    }
                });
                // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
                captchaObj.appendTo("#embed-captcha");
                captchaObj.onReady(function () {
                    $("#wait")[0].className = "layui-hide";
                });
                // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
            };
            $.ajax({
                // 获取id，challenge，success（是否启用failback）
                url: "{{ url('captcha') }}?t=" + (new Date()).getTime(), // 加随机数防止缓存
                type: "get",
                dataType: "json",
                success: function (data) {
                    //console.log(data);
                    // 使用initGeetest接口
                    // 参数1：配置参数
                    // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
                    initGeetest({
                        gt: data.gt,
                        challenge: data.challenge,
                        new_captcha: data.new_captcha,
                        product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                        offline: !data.success, // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                        width: '100%'
                        // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
                    }, handlerEmbed);
                }
            });
        });
    </script>
@endsection